﻿/*
    新增日期:2010-4-12 
 *    创建人:叶燕鑫
 *  內容说明:佳士通网站 出错处理基类
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace YWTSSys.Web
{
    
    public class WebException : Exception
    {
        /// <summary>
        /// 引发此错误导向的URL地址
        /// </summary>
        public virtual string RedirectURL
        {
            get
            {
                return "/MachineSys/Login.aspx"; ;
            }
        }
        /// <summary>
        /// 返回URL
        /// </summary>
        public virtual string ReturnURL
        {
            get
            {
                string _ReturnURL = HttpContext.Current.Request.Url.AbsoluteUri;
                return _ReturnURL;
            }
        }
        /// <summary>
        /// 处理出错结果
        /// </summary>
        public virtual void Handle()
        {
            if (string.IsNullOrEmpty(RedirectURL))
                return;
            string RedirectURLJS = "<script>top.location.href='{0}?errormsg={1}&returnurl={2}';</script>";
            RedirectURLJS = string.Format(RedirectURLJS, RedirectURL, base.Message, ReturnURL);

            HttpContext.Current.Response.Write(RedirectURLJS);
        }

        public WebException() : base() { }

        public WebException(string msg)
            : base(msg)
        {

        }

    }
    
   
}
